
let a = 100, b = 50, c = 2 , d = 4;
// 依次完成加减乘除操作
console.log( ( 100 - 50 ) * 2 / 4);

const executor = (fulfill, reject) => {
    fulfill(a);
}

let p = new Promise( executor );

p.then(function(prev){
    console.log('上一个Promise实例中包裹的结果是: ' + prev );
    return prev - b;
}).then(function(prev){
    console.log('上一个Promise实例中包裹的结果是: ' + prev );
    return prev * c;
}).then(function(prev){
    console.log('上一个Promise实例中包裹的结果是: ' + prev );
    if(d == 0 ) {
        throw new Error('除数不能为零');
    }
    return prev / d;
}).then( prev => console.log( prev ) )
  .catch( error => console.log(error) )
  .finally( () => console.log('end') );